<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Views/Shared/Iframe.Master" %>

<asp:Content ID="cJScripts" runat="server" ContentPlaceHolderID="cphJScripts">
    <script type="text/javascript">
        $(document).ready(function () {
            $(".blockButton .green").click(function () {
                resize();
                $(this).addClass("loading");
                if (!$("#contentPage form").valid()) {
                    resize();
                    $(this).removeClass("loading");
                } else {
                    $("form")[0].submit();
                }
            })

            $(".blockButton .blue").click(function () {
                validator.resetForm();
                $('form')[0].reset();
                resize();
                toggelSection();
            })

            $("#SlFunctions").change(function () {
                (this.selectedIndex == 1 || this.selectedIndex == 2) ? $("#selectSection").show("normal") : $("#selectSection").hide("normal");
            });

            toggelSection();

            // Validation

            var container = $('#error');
            var validator = $("form").validate({
                errorContainer: container,
                errorLabelContainer: $("ul", container),
                wrapper: 'li',
                unhighlight: function (element, errorClass) {
                    resize();
                },

                rules: {
                    Title: {
                        required: true
                    },
                    Description: {
                        maxlength: 250,
                        required: true
                    },
                    URL: {
                        url: true,
                        required: true
                    }
                },

                messages: {
                    Title: "<%= ScoutNET.Resources.Liens_Create_Title_Error_Required %>",
                    Description:
                    {
                        maxlength: "<%= ScoutNET.Resources.Liens_Create_Description_Error_Maxlength %>",
                        required: "<%= ScoutNET.Resources.Liens_Create_Description_Error_Required %>",
                    },
                    URL:
                    {
                        url: "<%= ScoutNET.Resources.Liens_Create_Url_Error_Url %>",
                        required: "<%= ScoutNET.Resources.Liens_Create_Url_Error_Required %>"
                    }
                }
            });
        });

        function toggelSection()
        {
            ($("#SlFunctions")[0].selectedIndex == 1 || $("#SlFunctions")[0].selectedIndex == 2) ? $("#selectSection").show("normal") : $("#selectSection").hide("normal");
            resize();
        }
    </script>
</asp:Content>

<asp:Content ID="cMainContent" runat="server" ContentPlaceHolderID="cphMainContent">
<div id="contentPage">
    
    <div id="error">
        <span class="validation-summary-errors"><%= ScoutNET.Resources.Master_Form_ErrorMessage %></span>
        <ul class="validation-summary-errors"></ul>
    </div>

    <% using (Html.BeginForm()) {%>
        <p><strong> <%= ScoutNET.Resources.Profil_Inscription_Subtitle1 %></strong></p>
        <% foreach (tSite_Section item in (List<tSite_Section>)ViewData["Sections"]){ %>
            <% string selected = (((List<tSite_Section>)ViewData["UserSections"]).Where(p => p.ID == item.ID).Count() > 0) ? "checked=\"checked\"" : string.Empty; %>
            <div class="blockINscription"><p><label for="section<%= item.ID %>"><%= item.Section %> : </label><input type="checkbox" id="section<%= item.ID %>" name="infoSection" value="<%= item.ID %>" <%= selected %> /></p></div>
        <% } %>
        <div class="clr"></div>

        <p><strong> <%= ScoutNET.Resources.Profil_Inscription_Subtitle2 %></strong></p>
	    <p>
		    <label for="SlSection"> <%= ScoutNET.Resources.Profil_Inscription_SlFunctions %> :</label>
		    <%= Html.DropDownList("SlFunctions")%>
	    </p>
		
	    <p id="selectSection" class="display">
		    <label for="SlSection"> <%= ScoutNET.Resources.Profil_Inscription_SlSection %> :</label>
		    <%= Html.DropDownList("SlSection")%>
	    </p>
        
        <div class="blockButton">	
	        <a class="mediumBtn green awesome" href="javascript:void(0);" title="<%= ScoutNET.Resources.Master_Button_Submit %>"><%= ScoutNET.Resources.Master_Button_Submit%></a>
	        <a class="mediumBtn blue awesome" href="javascript:void(0)" title="<%= ScoutNET.Resources.Master_Button_Reset %>"><%= ScoutNET.Resources.Master_Button_Reset%></a>
        </div>
    <% } %>
</div>
</asp:Content>